public class RotateWorld implements Action {

  float initX;
  float initY;
  float maxAngle;
  float minAngle;
  Node world;

  //Si se usa este constructor no se tiene restricción de ángulos
  public RotateWorld(Node world) {
    this.world = world;
  }
  
  
  //Constructor que permite definir limites de ángulos.
   public RotateWorld(Node world, float minAngle, float maxAngle) {
    this.world = world;
    this.maxAngle = maxAngle;
    this.minAngle = minAngle;
  }

  public void mouseDrag(float x, float y) {
    float rotationAngle = PI*(y-initY)*0.01;
    if(maxAngle != 0 && minAngle != 0) {
      if(rotationAngle < maxAngle && rotationAngle > minAngle) {
        this.world.setAngle(rotationAngle);  
      }
    }
    else {
        this.world.setAngle(rotationAngle);  
    }
  }

  public void mouseClick(float x, float y) {
  }

  void mousePress(float x, float y) {
    this.initX = x;
    this.initY = y;
  }
  void mouseMove(float x, float y) {
  }
}

